﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Dimok.Web.UI;

namespace AjaxMasterExtentions {
	public static class AjaxMasterExtentions {
		public static Profiler GetProfiler(this UserControl UserControl) {
			return UserControl.Page.GetProfiler();
		}
		public static Profiler GetProfiler(this UserControl UserControl, Control Control) {
			return UserControl.Page.GetProfiler(Control);
		}
		public static Profiler GetProfiler(this MasterPage master) {
			return master.Page.GetProfiler();
		}
		public static Profiler GetProfiler(this MasterPage master, Control Control) {
			return master.Page.GetProfiler(Control);
		}
		public static Profiler GetProfiler(this Page Page) {
			var rge = Find.ChildrenByType(Page, typeof(RadGridExtender)).FirstOrDefault();
			return Page.GetProfiler(rge != null ? rge : Page);
		}
		public static Profiler GetProfiler(this Page Page, Control Control) {
			return new Profiler(Control);
		}
		public static string UserFontSize(this MasterPage master, string FontSize) {
			var p = master.GetProfiler();
			p.Page.FontSize = FontSize;
			p.Save();
			return FontSize;
		}
		public static string UserFontSize(this MasterPage master) {
			return master.GetProfiler().Page.FontSize;
		}
	}

}